package net.esj.basic.pojo.proxy;

import java.lang.reflect.Method;

import net.esj.basic.pojo.AbstractPojo;

import javassist.util.proxy.MethodHandler;

public class DefaultPojoMethodHandler implements MethodHandler {

	/**
	 * TODO 将来可能植入service模块回去嵌套的对象
	 */
	@Override
	public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args)
			throws Throwable {
		if(thisMethod.getDeclaringClass() ==PojoProxy.class && "self".equals(thisMethod.getName())){
			return ((AbstractPojo)self).self;
		}
		
		return thisMethod.invoke(((AbstractPojo)self).self, args);
	}

}
